package it.amicosmanettone.finance.stocky.adapter;

import it.amicosmanettone.finance.stocky.R;
import it.amicosmanettone.finance.stocky.bean.SingleStockBean;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ListAdapterSearchStock extends ArrayAdapter {

	ArrayList<SingleStockBean> singleStockBeanListAdapter = null;
	private Context contextApp;

	public ListAdapterSearchStock(Context context, int textViewResourceId,
			ArrayList<SingleStockBean> singleStockBeanList) {
		super(context, textViewResourceId, singleStockBeanList);
		this.singleStockBeanListAdapter = singleStockBeanList;
		contextApp = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) getContext()
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		convertView = inflater.inflate(R.layout.row_stock_search, null);
		TextView nome = (TextView) convertView.findViewById(R.id.textViewName);
		TextView value = (TextView) convertView
				.findViewById(R.id.textViewValue);

		Typeface robotoThin = Typeface.createFromAsset(contextApp.getAssets(),
				"Roboto-Thin.ttf");
		value.setTypeface(robotoThin);
		value.refreshDrawableState();

		nome.setText(this.singleStockBeanListAdapter.get(position)
				.getStockName());
		value.setText("("
				+ this.singleStockBeanListAdapter.get(position)
						.getStockSymbol() + ")");

		return convertView;

	}

}